package com.monitor.action.user;

import java.io.PrintWriter;

import com.monitor.action.MonitorActionSupport;
import com.monitor.po.Album;
import com.monitor.service.AlbumService;
import com.monitor.util.Constants;
import com.monitor.util.Pager;

public class AlbumAction extends MonitorActionSupport {

	private static final long serialVersionUID = -2912403249125021814L;
	private long uid;
	private AlbumService albumService;
	private int cPage;
	private Pager<Album> albums;
	private long aid;

	@Override
	public String execute() throws Exception {
		cPage = cPage < 1 ? 1 : cPage;
		long _uid = getUid(uid);
		albums = albumService.getAlbumByUid(_uid, Constants.DEFAULT_PAGESIEZE, cPage);
		return SUCCESS;
	}

	public void deleteAlbum() throws Exception {
		long _uid = getUid(uid);
		PrintWriter out = getWriter();
		boolean success = albumService.deleteAlbum(_uid, aid);
		if (success) {
			out.print("success");
		} else {
			out.print("failed");
		}
		out.flush();
		out.close();
	}

	public long getUid() {
		return uid;
	}

	public void setUid(long uid) {
		this.uid = uid;
	}

	public AlbumService getAlbumService() {
		return albumService;
	}

	public void setAlbumService(AlbumService albumService) {
		this.albumService = albumService;
	}

	public int getcPage() {
		return cPage;
	}

	public void setcPage(int cPage) {
		this.cPage = cPage;
	}

	public Pager<Album> getAlbums() {
		return albums;
	}

	public void setAlbums(Pager<Album> albums) {
		this.albums = albums;
	}

	public long getAid() {
		return aid;
	}

	public void setAid(long aid) {
		this.aid = aid;
	}

}
